package wps

import (
	"github.com/zzl/go-com/com"
	"github.com/zzl/go-com/ole"
	"github.com/zzl/go-win32api/v2/win32"
	"syscall"
	"unsafe"
)

// 000244D3-0000-0000-C000-000000000046
var IID_TextConnection = syscall.GUID{0x000244D3, 0x0000, 0x0000,
	[8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}

type TextConnection struct {
	ole.OleClient
}

func NewTextConnection(pDisp *win32.IDispatch, addRef bool, scoped bool) *TextConnection {
	if pDisp == nil {
		return nil
	}
	p := &TextConnection{ole.OleClient{pDisp}}
	if addRef {
		pDisp.AddRef()
	}
	if scoped {
		com.AddToScope(p)
	}
	return p
}

func TextConnectionFromVar(v ole.Variant) *TextConnection {
	return NewTextConnection(v.IDispatch(), false, false)
}

func (this *TextConnection) IID() *syscall.GUID {
	return &IID_TextConnection
}

func (this *TextConnection) GetIDispatch(addRef bool) *win32.IDispatch {
	if addRef {
		this.AddRef()
	}
	return this.IDispatch
}

func (this *TextConnection) QueryInterface_(riid *syscall.GUID, ppvObj unsafe.Pointer) {
	retVal, _ := this.Call(0x60000000, []interface{}{riid, ppvObj})
	_ = retVal
}

func (this *TextConnection) AddRef() uint32 {
	retVal, _ := this.Call(0x60000001, nil)
	return retVal.UintValVal()
}

func (this *TextConnection) Release() uint32 {
	retVal, _ := this.Call(0x60000002, nil)
	return retVal.UintValVal()
}

func (this *TextConnection) GetTypeInfoCount(pctinfo *uint32) {
	retVal, _ := this.Call(0x60010000, []interface{}{pctinfo})
	_ = retVal
}

func (this *TextConnection) GetTypeInfo(itinfo uint32, lcid uint32, pptinfo unsafe.Pointer) {
	retVal, _ := this.Call(0x60010001, []interface{}{itinfo, lcid, pptinfo})
	_ = retVal
}

func (this *TextConnection) GetIDsOfNames(riid *syscall.GUID, rgszNames **int8, cNames uint32, lcid uint32, rgdispid *int32) {
	retVal, _ := this.Call(0x60010002, []interface{}{riid, rgszNames, cNames, lcid, rgdispid})
	_ = retVal
}

func (this *TextConnection) Invoke(dispidMember int32, riid *syscall.GUID, lcid uint32, wFlags uint16, pdispparams *win32.DISPPARAMS, pvarResult *ole.Variant, pexcepinfo *win32.EXCEPINFO, puArgErr *uint32) {
	retVal, _ := this.Call(0x60010003, []interface{}{dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr})
	_ = retVal
}

func (this *TextConnection) Application() *Application {
	retVal, _ := this.PropGet(0x00000094, nil)
	return NewApplication(retVal.IDispatch(), false, true)
}

func (this *TextConnection) Creator() int32 {
	retVal, _ := this.PropGet(0x00000095, nil)
	return retVal.LValVal()
}

func (this *TextConnection) Parent() *ole.DispatchClass {
	retVal, _ := this.PropGet(0x00000096, nil)
	return ole.NewDispatchClass(retVal.IDispatch(), true)
}

func (this *TextConnection) Connection() ole.Variant {
	retVal, _ := this.PropGet(0x00000598, nil)
	com.AddToScope(retVal)
	return *retVal
}

func (this *TextConnection) SetConnection(rhs interface{}) {
	_ = this.PropPut(0x00000598, []interface{}{rhs})
}

func (this *TextConnection) TextFileHeaderRow() bool {
	retVal, _ := this.PropGet(0x00000c2e, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileHeaderRow(rhs bool) {
	_ = this.PropPut(0x00000c2e, []interface{}{rhs})
}

func (this *TextConnection) TextFileColumnDataTypes() ole.Variant {
	retVal, _ := this.PropGet(0x00000749, nil)
	com.AddToScope(retVal)
	return *retVal
}

func (this *TextConnection) SetTextFileColumnDataTypes(rhs interface{}) {
	_ = this.PropPut(0x00000749, []interface{}{rhs})
}

func (this *TextConnection) TextFileCommaDelimiter() bool {
	retVal, _ := this.PropGet(0x00000746, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileCommaDelimiter(rhs bool) {
	_ = this.PropPut(0x00000746, []interface{}{rhs})
}

func (this *TextConnection) TextFileConsecutiveDelimiter() bool {
	retVal, _ := this.PropGet(0x00000743, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileConsecutiveDelimiter(rhs bool) {
	_ = this.PropPut(0x00000743, []interface{}{rhs})
}

func (this *TextConnection) TextFileDecimalSeparator() string {
	retVal, _ := this.PropGet(0x0000074e, nil)
	return win32.BstrToStrAndFree(retVal.BstrValVal())
}

func (this *TextConnection) SetTextFileDecimalSeparator(rhs string) {
	_ = this.PropPut(0x0000074e, []interface{}{rhs})
}

func (this *TextConnection) TextFileFixedColumnWidths() ole.Variant {
	retVal, _ := this.PropGet(0x0000074a, nil)
	com.AddToScope(retVal)
	return *retVal
}

func (this *TextConnection) SetTextFileFixedColumnWidths(rhs interface{}) {
	_ = this.PropPut(0x0000074a, []interface{}{rhs})
}

func (this *TextConnection) TextFileOtherDelimiter() string {
	retVal, _ := this.PropGet(0x00000748, nil)
	return win32.BstrToStrAndFree(retVal.BstrValVal())
}

func (this *TextConnection) SetTextFileOtherDelimiter(rhs string) {
	_ = this.PropPut(0x00000748, []interface{}{rhs})
}

func (this *TextConnection) TextFileParseType() int32 {
	retVal, _ := this.PropGet(0x00000741, nil)
	return retVal.LValVal()
}

func (this *TextConnection) SetTextFileParseType(rhs int32) {
	_ = this.PropPut(0x00000741, []interface{}{rhs})
}

func (this *TextConnection) TextFilePlatform() int32 {
	retVal, _ := this.PropGet(0x0000073f, nil)
	return retVal.LValVal()
}

func (this *TextConnection) SetTextFilePlatform(rhs int32) {
	_ = this.PropPut(0x0000073f, []interface{}{rhs})
}

func (this *TextConnection) TextFilePromptOnRefresh() bool {
	retVal, _ := this.PropGet(0x0000074d, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFilePromptOnRefresh(rhs bool) {
	_ = this.PropPut(0x0000074d, []interface{}{rhs})
}

func (this *TextConnection) TextFileSemicolonDelimiter() bool {
	retVal, _ := this.PropGet(0x00000745, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileSemicolonDelimiter(rhs bool) {
	_ = this.PropPut(0x00000745, []interface{}{rhs})
}

func (this *TextConnection) TextFileSpaceDelimiter() bool {
	retVal, _ := this.PropGet(0x00000747, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileSpaceDelimiter(rhs bool) {
	_ = this.PropPut(0x00000747, []interface{}{rhs})
}

func (this *TextConnection) TextFileStartRow() int32 {
	retVal, _ := this.PropGet(0x00000740, nil)
	return retVal.LValVal()
}

func (this *TextConnection) SetTextFileStartRow(rhs int32) {
	_ = this.PropPut(0x00000740, []interface{}{rhs})
}

func (this *TextConnection) TextFileTabDelimiter() bool {
	retVal, _ := this.PropGet(0x00000744, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileTabDelimiter(rhs bool) {
	_ = this.PropPut(0x00000744, []interface{}{rhs})
}

func (this *TextConnection) TextFileTextQualifier() int32 {
	retVal, _ := this.PropGet(0x00000742, nil)
	return retVal.LValVal()
}

func (this *TextConnection) SetTextFileTextQualifier(rhs int32) {
	_ = this.PropPut(0x00000742, []interface{}{rhs})
}

func (this *TextConnection) TextFileThousandsSeparator() string {
	retVal, _ := this.PropGet(0x0000074f, nil)
	return win32.BstrToStrAndFree(retVal.BstrValVal())
}

func (this *TextConnection) SetTextFileThousandsSeparator(rhs string) {
	_ = this.PropPut(0x0000074f, []interface{}{rhs})
}

func (this *TextConnection) TextFileTrailingMinusNumbers() bool {
	retVal, _ := this.PropGet(0x00000874, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *TextConnection) SetTextFileTrailingMinusNumbers(rhs bool) {
	_ = this.PropPut(0x00000874, []interface{}{rhs})
}

func (this *TextConnection) TextFileVisualLayout() int32 {
	retVal, _ := this.PropGet(0x000008c5, nil)
	return retVal.LValVal()
}

func (this *TextConnection) SetTextFileVisualLayout(rhs int32) {
	_ = this.PropPut(0x000008c5, []interface{}{rhs})
}
